using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
namespace DAL
{
    public class PhotoVotes : DAL.DataManager<PhotoVote>
    {
        private static PhotoVotes Instance = new PhotoVotes();
        static PhotoVotes() { }

        public override string TableName
        {
            get { return @"awesome_votes"; }
        }

        protected override void CopyToItem(DataRow Row, PhotoVote Item)
        {
            Item.User = Users.Item(Convert.ToInt64(Row["UserID"]));

            Item.Picture = Photos.Item(Convert.ToInt64(Row["PictureID"]));
        }

        protected override void CopyFromItem(DataManagerQuery query, PhotoVote Item)
        {
            query.AddParam("UserID", Item.User.ID);

            query.AddParam("PictureID", Item.Picture.ID);
        }

        public static PhotoVote Item(Int64 id)
        {
            return Instance.GetItem(id);
        }

        public static List<PhotoVote> All()
        {
            return Instance.GetItems();
        }

        public static void Add(PhotoVote Item)
        {
            Instance.Insert(Item);
        }

        public static void Save(PhotoVote Item)
        {
            Instance.Update(Item);
        }
    }

    public class PhotoVote : DAL.DataManagerRow
    {
        private User _User;
        public User User
        {
            get
            {
                return _User;
            }
            set
            {
                _User = value;
            }
        }

        private Photo _Picture;
        public Photo Picture
        {
            get
            {
                return _Picture;
            }
            set
            {
                _Picture = value;
            }
        }
    }
}